/**
 * This file is part of routerdns.
 * 
 * AUTHORS
 *     Oliver Mader  <dotb52@gmail.com>
 * 
 * Copyright (C) 2009  Oliver Mader
 * 
 * Routerdns is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Routerdns is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with routerdns.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "routerdns.h"

#include "options.h"
#include "net.h"

#define VERSION "0.1"

/* entry point */
int main(int argc, char *argv[])
{
	/* rdns settings object */
	routerdns_t rdns;
	
	/* default values */
	rdns.username = NULL;
	rdns.password = NULL;
	rdns.hostname = NULL;
	rdns.ip = NULL;
	rdns.wildcard = NOCHANGE;
	rdns.mx = NULL;
	rdns.backmx = NOCHANGE;
	rdns.offline = NOCHANGE;
	rdns.verbose = OFF;
	
	/* parse the commandline options */
	options_parse(&rdns, argc, argv);
	
	/* start the update request */
	net_update_ip(&rdns);
	/*
	char ip[16];
	net_current_ip(ip);
	*/
	
	return 0;
}

/* prints the usage information and exit */
extern void usage()
{
	printf("Usage: routerdns [OPTION]...\n"
		"\n"
		"OPTIONS\n"
		"  -c, --config=FILE        Read an optional configuration FILE\n"
		"  -u, --username=USER      The username to use (required)\n"
		"  -p, --password=PASS      The password to use (required)\n"
		"  -h, --hostname=HOST      A comma seperated list of hostnames "
		"(required)\n"
		"  -i, --ip=IP              IP address to set for the update\n"
		"  -w, --wildcard=[on/off]  Parameter enables or disables wildcards "
		"for HOSTNAME\n"
		"  -m, --mx=HOST            Specifies a Mail eXchanger for use with "
		"HOSTNAME\n"
		"  -b, --backmx=[on/off]    Requests the MX in the previous parameter "
		"to be set\n                           up as a backup MX by listing the"
		" host itself as an \n                           MX with a lower "
		"preference value\n"
		"  -o, --offline=[on/off]   Sets the hostname to offline mode\n"
		"\n"
		"  -v, --verbose            Be verbose\n"
		"      --help               Show this help and exit\n"
		"      --version            Show version and exit\n");
	
	exit(EXIT_SUCCESS);
}

/* prints the program version and exit */
extern void version()
{
	printf("routerdns " VERSION "\n");
	
	exit(EXIT_SUCCESS);
}
